package br.com.equus.entidade;

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.envers.Audited;

import br.com.arquitetura.entidade.Entidade;

@Entity
@Table(name = "EQ_TRANSFERENCIA_ANIMAL", catalog = "EQUUS")
@Audited
public class TransferenciaAnimal extends Entidade<Integer> {

	private static final long serialVersionUID = 4041732843580427323L;

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ID_TRANFERENCIA_ANIMAL", unique = true, nullable = false)
	private Integer id;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_FUNCAO_ANIMAL", referencedColumnName = "ID_FUNCAO_ANIMAL", nullable = false)
	private FuncaoAnimal funcaoAnimal;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_ANIMAL", referencedColumnName = "ID_ANIMAL")
	private Animal animal;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "DT_TRANFERENCIA", nullable = false)
	private Date dtTransferencia;

	@Column(name = "DSC_OBSERVACAO", columnDefinition = "text")
	private String observacao;

	public TransferenciaAnimal() {
	}

	public TransferenciaAnimal(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public FuncaoAnimal getFuncaoAnimal() {
		return funcaoAnimal;
	}

	public void setFuncaoAnimal(FuncaoAnimal funcaoAnimal) {
		this.funcaoAnimal = funcaoAnimal;
	}

	public Animal getAnimal() {
		return animal;
	}

	public void setAnimal(Animal animal) {
		this.animal = animal;
	}

	public Date getDtTransferencia() {
		return dtTransferencia;
	}

	public void setDtTransferencia(Date dtTransferencia) {
		this.dtTransferencia = dtTransferencia;
	}

	public String getObservacao() {
		return observacao;
	}

	public void setObservacao(String observacao) {
		this.observacao = observacao;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((animal == null) ? 0 : animal.hashCode());
		result = prime * result + ((dtTransferencia == null) ? 0 : dtTransferencia.hashCode());
		result = prime * result + ((funcaoAnimal == null) ? 0 : funcaoAnimal.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((observacao == null) ? 0 : observacao.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TransferenciaAnimal other = (TransferenciaAnimal) obj;
		if (animal == null) {
			if (other.animal != null)
				return false;
		} else if (!animal.equals(other.animal))
			return false;
		if (dtTransferencia == null) {
			if (other.dtTransferencia != null)
				return false;
		} else if (!dtTransferencia.equals(other.dtTransferencia))
			return false;
		if (funcaoAnimal == null) {
			if (other.funcaoAnimal != null)
				return false;
		} else if (!funcaoAnimal.equals(other.funcaoAnimal))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (observacao == null) {
			if (other.observacao != null)
				return false;
		} else if (!observacao.equals(other.observacao))
			return false;
		return true;
	}

}
